package com.umeox.moto.watch.themes.skin.entity;

import android.view.View;
import android.widget.Switch;

import androidx.appcompat.widget.SwitchCompat;

import com.umeox.moto.watch.themes.skin.loader.ResourceManager;

/**
 * Created by Rambo 2023/10/11
 * Describe:
 */
public class SwitchAttr extends SkinAttr {

    @Override
    public void apply(View view) {
        if (view instanceof Switch) {
            Switch aSwitch = (Switch) view;

            if (RES_TYPE_NAME_DRAWABLE.equals(attrValueTypeName)) {
                if (AttrFactory.THUMB.equals(attrName)) {
                    aSwitch.setThumbDrawable(ResourceManager.getInstance().getDrawable(attrValueRefId));
                } else if (AttrFactory.SWITCH_TRACK.equals(attrName)) {
                    aSwitch.setTrackDrawable(ResourceManager.getInstance().getDrawable(attrValueRefId));
                }
            }
        } else if (view instanceof SwitchCompat) {
            SwitchCompat aSwitch = (SwitchCompat) view;
            if (RES_TYPE_NAME_DRAWABLE.equals(attrValueTypeName)) {
                if (AttrFactory.THUMB.equals(attrName)) {
                    aSwitch.setThumbDrawable(ResourceManager.getInstance().getDrawable(attrValueRefId));
                } else if (AttrFactory.SWITCH_TRACK.equals(attrName)) {
                    aSwitch.setTrackDrawable(ResourceManager.getInstance().getDrawable(attrValueRefId));
                }
            }
        }
    }
}
